package halberd.utils;

public class RGBUtils {
	/**
	 * rgb
	 * 
	 * @param r
	 * @param g
	 * @param b
	 * @return
	 */
	public static int rgb2gray(int r, int g, int b) {
		int h = ((r * 38 + g * 75 + b * 15) >> 7);
		h = h > 255 ? 255 : (h<0?0:h);
		return h;
	}

	public static int clamp255(int x) {
		return (x < 0 ? 0 : (x > 255 ? 255 : x));
	}
}
